
<template>
  <div class="dashboard-editor-container">
    <!-- <el-row class="chart-wrapper">
      <h4> 店铺名称：{{ message.merchantName }}</h4>
    </el-row> -->
    <panel-group @handleSetLineChartData="handleSetLineChartData" />
    <!-- 统计图 -->
    <!-- <el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;">
      <div class="filter-item">
        <el-date-picker
          v-model="dateTime"
          style="width: 400px; margin-left: 2%;"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          format="yyyy - MM - dd"
          value-format="timestamp"/>
        <el-button class="filter-item" type="primary" icon="el-icon-search" @click="get_data_statistics_info()">搜索</el-button>
      </div>
      <line-chart :chart-data="lineChartData" />
    </el-row> -->
  </div>
</template>

<script>
import GithubCorner from '@/components/GithubCorner'
import PanelGroup from './components/PanelGroup'
import LineChart from './components/LineChart'
import RaddarChart from './components/RaddarChart'
import PieChart from './components/PieChart'
import BarChart from './components/BarChart'
import TransactionTable from './components/TransactionTable'
import TodoList from './components/TodoList'
import BoxCard from './components/BoxCard'
const lineChartData = {
  newVisitis: {
    expectedData: [100, 120, 161, 134, 105, 160, 165],
    actualData: [120, 82, 91, 154, 162, 140, 145]
  },
  messages: {
    expectedData: [200, 192, 120, 144, 160, 130, 140],
    actualData: [180, 160, 151, 106, 145, 150, 130]
  },
  purchases: {
    expectedData: [80, 100, 121, 104, 105, 90, 100],
    actualData: [120, 90, 100, 138, 142, 130, 130]
  },
  shoppings: {
    expectedData: [130, 140, 141, 142, 145, 150, 160],
    actualData: [120, 82, 91, 154, 162, 140, 130]
  }
}
export default {
  name: 'DashboardAdmin',
  components: {
    GithubCorner,
    PanelGroup,
    LineChart,
    RaddarChart,
    PieChart,
    BarChart,
    TransactionTable,
    TodoList,
    BoxCard
  },
  data() {
    return {
      dateTime: '',
      // message: [],
      lineChartData: {
        exchang_numData: [],
        sale_after_numData: [],
        trading_amountData: [],
        user_numData: [],
        xAxis_data: []
      },
      obj: {
        exchang_numData: [],
        sale_after_numData: [],
        trading_amountData: [],
        user_numData: [],
        xAxis_data: []
      },
      count: []
    }
  },
  created: function() {
    // this.get_data_statistics_info()
  },
  methods: {
    timestampToTime(timestamp) {
      var date = new Date(timestamp)
      var Y = date.getFullYear() + '-'
      var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
      var D = date.getDate()
      return Y + M + D
    },
    // get_data_statistics_info() {
    //   let time = ''
    //   let end_time = ''
    //   const day = 60 * 60 * 24
    //   if (this.dateTime.length > 0) {
    //     end_time = this.dateTime[1].toString().substring(0, 10)
    //     time = this.dateTime[0].toString().substring(0, 10)
    //     const utc = end_time - time
    //     const dif = utc / day + 1
    //     if (dif > 14) {
    //       this.$message({
    //         showClose: true,
    //         message: '查询时间不可超过15天，当前查询日期：' + this.timestampToTime(this.dateTime[0]) + '至' + this.timestampToTime(this.dateTime[1]) + '，总天数：' + dif,
    //         type: 'warning'
    //       })
    //       return false
    //     }
    //   } else {
    //     end_time = (new Date().getTime()).toString().substring(0, 10)
    //     time = end_time - day * 6
    //   }
    // },
    handleSetLineChartData(type) {
      this.lineChartData = lineChartData[type]
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .dashboard-editor-container {
    padding: 32px;
    background-color: rgb(240, 242, 245);
    .chart-wrapper {
      background: #fff;
      padding: 16px 16px 0;
      margin-bottom: 32px;
    }
  }
</style>
